
//preloading.....
load("library/common.js");

JEuler.system.loadJS("library/math.js");

(function() {

    //JEuler.system.loadJS("data/???.dat");
    JEuler.system.printCaption("51");
    JEuler.system.startTimerCount();


    JEuler.math.PrimeUtils.sievePrime(1000000);
    var primes = JEuler.math.PrimeUtils.getPrimePool();
    
    var countDigit = function(num) {
        if(num>=100000) return 6;
        if(num>=10000) return 5;
        if(num>=1000) return 4;
        if(num>=100) return 3;
        if(num>=10) return 2;
        return 1;
    }
    
    var convert = function(num) {
        var hash=[], tmp=num, list=[], t;
        for(var i=0; i<=9; i++) hash[i]=0;
        do {
            t = tmp%10;
            hash[t] = hash[t] + 1;
            list.push(t);
            tmp = (tmp-t)/10;
        }while(tmp>0);
        return {list: list, hash: hash}
    }
    
    function test(number, digit, size) {
        var n = [];
        for(var i=0; i<number.length; i++) 
            n[i] = number[number.length-1-i];
        
        
    }
    
    
   var d;   
   for(var i=0; i<primes.length; i++) {
        if(primes[i]<1000) continue;
        d = covert(primes[i]);
        for(var j=1; j<d.list.length; j++) {
            if(d.hash[0]>=j) {
            }
            if(d.hash[1]>=j) {
            }
            if(d.hash[2]>=j) {
            }
        }
    }

    JEuler.system.print("SUM=" + sum);
    JEuler.system.printTimerCount();
    
})();
